const Koa = require('koa')
const app = new Koa()

const KoaBody = require('koa-body')
app.use(KoaBody())

const { printLog } = require('../middleware/app.middleware')
app.use(printLog)

const router = require('../router')
app
  .use(router.routes())
  .use(router.allowedMethods())

const errHandler = require('./errHandler')
app.on('error', errHandler)

module.exports = app